package light.im.loginserver.domain.user;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import light.im.loginserver.domain.dal.DAException;
import light.im.loginserver.domain.dal.UserDAO;
import light.im.loginserver.domain.user.model.User;

public class UserService {

	private static Logger logger = LoggerFactory.getLogger(UserService.class);
	
	public static User validate(String userId, String psw)
	{
		User user;
		if(userId.equals("ruby") )
		{
		    user = new User();
		    user.setId(userId);
		    user.setUserId(userId);
		    user.setPassword(psw);
		    return user;
		}
		try {
			user = UserDAO.getInstance().getUser(userId);
			if(user==null)
				return null;
			if(psw!=null && psw.equals(user.getPassword()))
				return user;
		} catch (DAException e) {
			logger.error("Failed to find user of \'"+userId+"\', for db error. "+e.toString());
			return null;
		}
		return null;
	}
	
	public static List<User> getFriends(String user)
	{
		List<User> us = new ArrayList<User>();
		return us;
	}
}
